export default {
  namespaced: true,
  state: {
    user: {
      userId: '',
      roles: [], //"ROLE_USER",
      token: localStorage.getItem("token") ? localStorage.getItem('token') : ''
    },
  },
  mutations: {
    setUserInfo (state, { userId, roles, token }) {
      state.user.userId = userId;
      state.user.token = token;
      state.user.roles = roles;
      localStorage.setItem('token', token);
    },
    deleteUser (state) {
      state.user = {
        userId: '',
        token: '',
        roles: []
      }
      localStorage.removeItem('token');
    }
  },

}